<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>AngelScript: Objects and handles</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>


</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">AngelScript
   
   </div>
   
  </td>
  
  
  
   
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.5.1 -->
</div>
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
  initNavTree('doc_datatypes_obj.html','');
</script>
<div id="doc-content">
<div class="header">
  <div class="headertitle">
<div class="title">Objects and handles </div>  </div>
</div>
<div class="contents">
<div class="textblock"><h2><a class="anchor" id="objects"></a>
Objects</h2>
<p>There are two forms of objects, reference types and value types.</p>
<p>Value types behave much like the primitive types, in that they are allocated on the stack and deallocated when the variable goes out of scope. Only the application can register these types, so you need to check with the application's documentation for more information about the registered types.</p>
<p>Reference types are allocated on the memory heap, and may outlive the initial variable that allocates them if another reference to the instance is kept. All <a class="el" href="doc_global.html#doc_global_class">script declared classes</a> are reference types. <a class="el" href="doc_global.html#doc_global_interface">Interfaces</a> are a special form of reference types, that cannot be instanciated, but can be used to access the objects that implement the interfaces without knowing exactly what type of object it is.</p>
<pre>
  obj o;      // An object is instanciated
  o = obj();  // A temporary instance is created whose 
              // value is assigned to the variable
</pre><h2><a class="anchor" id="handles"></a>
Object handles</h2>
<p>Object handles are a special type that can be used to hold references to other objects. When calling methods or accessing properties on a variable that is an object handle you will be accessing the actual object that the handle references, just as if it was an alias. Note that unless initialized with the handle of an object, the handle is <code>null</code>.</p>
<pre>
  obj o;
  obj@ a;           // a is initialized to null
  obj@ b = @o;      // b holds a reference to o</pre><pre>  b.ModifyMe();     // The method modifies the original object</pre><pre>  if( a is null )   // Verify if the object points to an object
  {
    @a = @b;        // Make a hold a reference to the same object as b
  }
</pre><p>Not all types allow a handle to be taken. Neither of the primitive types can have handles, and there may exist some object types that do not allow handles. Which objects allow handles or not, are up to the application that registers them.</p>
<p>Object handle and array type modifiers can be combined to form handles to arrays, or arrays of handles, etc.</p>
<dl class="see"><dt><b>See also:</b></dt><dd><a class="el" href="doc_script_handle.html">Object handles</a> </dd></dl>
</div></div>
</div>
  <div id="nav-path" class="navpath">
    <ul>

    <li class="footer">Generated on Sun Jan 29 2012 15:41:04 for AngelScript by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.5.1 </li>
   </ul>
 </div>


</body>
</html>
